package cn.laixueit.controller;

import cn.laixueit.service.BookService;
import cn.laixueit.service.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CacheRedisController {

    @Autowired
    private ChapterService chapterService;
    @Autowired
    private BookService bookService;

    @RequestMapping("/cache/book")
    public String cacheBook(){
        try {
            bookService.cache();
            return "ok";
        }catch (Exception e){
            e.printStackTrace();
            return "缓存失败";
        }
    }

    @RequestMapping("/cache/chapter")
    public String cacheChapter(){
        try {
            chapterService.cache();
            return "ok";
        }catch (Exception e){
            e.printStackTrace();
            return "缓存失败";
        }
    }
}
